#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
开放商户 - 微信实名认证查询功能使用示例
"""

import os
import sys

# 添加项目根目录到Python路径，确保能够导入jlpay包
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))

from examples.base_example import BaseExample
from jlpay.services.openmerch.wechat.wechat_realname_query_service import WechatRealnameQueryService
from jlpay.model.openmerch.wechat.wechat_realname_query import RealnameWxQueryRequest


class WechatRealnameQueryExample(BaseExample):
    """微信实名认证查询示例类"""
    
    def __init__(self):
        """初始化示例类"""
        super().__init__("examples.openmerch.wechat.wechat_realname_query")
        # 创建微信实名认证查询服务实例
        self.wechat_realname_query_service = WechatRealnameQueryService(self.config)
    
    def build_realname_wx_query_request(self):
        """构建微信实名认证查询请求"""
        # 创建请求对象
        request = RealnameWxQueryRequest()
        
        # 设置请求参数
        request.set_merch_no("849584358140020")
        request.set_query_type("0")  # 申请单查询
        
        return request
    
    def demo(self):
        """执行微信实名认证查询示例"""
        self.logger.info("开始执行微信实名认证查询示例")
        
        # 构建请求
        request = self.build_realname_wx_query_request()
        
        # 发送请求并处理响应
        self.send_request_and_handle_response(
            self.wechat_realname_query_service.query_realname_wx,
            "微信实名认证查询",
            request
        )
        
        self.logger.info("微信实名认证查询示例执行完毕")


if __name__ == "__main__":
    example = WechatRealnameQueryExample()
    example.logger.info("=" * 50)
    example.logger.info("===== 微信实名认证查询示例 开始 =====")
    example.logger.info("=" * 50)
    
    example.demo()
    
    example.logger.info("=" * 50)
    example.logger.info("===== 微信实名认证查询示例执行完毕 =====")
    example.logger.info("=" * 50) 